home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr52 / ncclib.zip / NCCDEMO.ZIP / G_MAIN.PRG < prev    next >
Text File  |  1992-11-03  |  8KB  |  289 lines

  1. //═══════════════════════════════════════════════════════╕
  2. //  Program .....: G_Main                                │
  3. //  CopyRight ...: 1992 National Computer Consultants    │
  4. //                 All rights are reserved.              │
  5. //  Author ......: Greg Rice                             │
  6. //═══════════════════════════════════════════════════════╛
  7.  
  8. #include "g_menu.ch"
  9. #include "inkey.ch"
  10. #include "g_event.ch"
  11. #include "Mouse.ch"
  12.  
  13.  
  14. Function Main(p1,p2,p3,p4,p5)
  15.  
  16.     local oldblink   := SetBlink( .f. )                            , ;
  17.           Event      := 0                                          , ;
  18.           nKey       := 0                                          , ;
  19.           vTemp      := NIL                                        , ;
  20.           Bar                                                      , ;
  21.           Mouse                                                    , ;
  22.           mForce                                                   , ;
  23.           i
  24.  
  25.  
  26.     Set Wrap On
  27.     Set Score Off
  28.     SetCancel( .f. )
  29.  
  30.  
  31.     i := GETENV("USE")
  32.     IF ! empty(i)
  33.       p5 := '@'+i
  34.  
  35.     END
  36.  
  37.     ParamPlace(p1)
  38.     ParamPlace(p2)
  39.     ParamPlace(p3)
  40.     ParamPlace(p4)
  41.     ParamPlace(p5)
  42.  
  43.     IF ".INI" $ uppe(DosParamList(5))
  44.       config()
  45.     END
  46.  
  47.     SaveMode( DisplayMode( ) )
  48.     if ! Empty( dosParamList(3) )
  49.       DisplayMode( dosParamList(3) )
  50.     endif
  51.     ColorSetup(dosParamList(3))
  52.  
  53.  
  54.     if '/C1' $ uppe(dosparamlist(3))
  55.       bar_color( 'N/BG*,GR+/RB')
  56.     elseif '/C2' $ uppe(dosparamlist(3))
  57.       bar_color( 'N/W*,R+/BG*')
  58.     elseif '/C3' $ uppe(dosparamlist(3))
  59.       bar_color( 'W+/B*,G+/N')
  60.     elseif '/C4' $ uppe(dosparamlist(3))
  61.       bar_color( 'N/G*, GR+/GR')
  62.     endif
  63.  
  64.  
  65.  
  66.     messageSet()
  67.     scroll()
  68.     SetColor( "W+/B" )
  69.     @0,0
  70.     NccMesg( 'National Computer Consultants Demo', 0, 'center' )
  71.     @0,1 say cDate( date() )
  72.     @0,maxcol()-7 say clock( 'on' )
  73.     setColor( 'B/W')
  74.     @12,00 say 'Initializing...'
  75.     SetColor( bar_color() )
  76.     Bar := MenuSys()
  77.  
  78.  
  79.     @maxrow(),00
  80.     set color to
  81.     set cursor off
  82.  
  83.     Showbackground()
  84.     Bar:Display()
  85.     Mouse := MouseSys()
  86.     Mouse:Activate()
  87.     Mouse:Hide()
  88.  
  89.     Bar:PromptActive( HELP_MOUSE, Mouse:isMouse )
  90.  
  91.     vTemp := ''
  92.     if ! Empty( dosParamList(1) )
  93.       vTemp :=  vTemp + 'F1' + dosParamList(1) + Chr( K_ENTER )
  94.     endif
  95.     if ! Empty( dosParamList(2) )
  96.       vTemp := vTemp + 'I' + dosParamList(2) + Chr( K_ENTER )
  97.     endif
  98.     if ! Empty( dosParamList(4) )
  99.       vTemp := vTemp + 'V' + subs(dosParamList(4),2) + Chr( K_ENTER )
  100.     endif
  101.  
  102.     if Empty( vTemp )
  103.       Bar:MenusActive := .t.
  104.       Bar:BarChoice( 2, .f. )
  105.       Bar:MenuChoice( 1, .f. )
  106.       mForce := .t.
  107.     else
  108.       Keyboard vTemp
  109.       mForce := .f.
  110.     endif
  111.  
  112.  
  113.     While Event # ev_SysExit                   //  Process while ! request to
  114.                                                //  terminate
  115.        if RedisplayBar()
  116.           RedisplayBar(.f.)
  117.          Bar:Display()
  118.        endif
  119.                                                //
  120.        Event := 0                              //
  121.        if Window_Active()                      //
  122.          Mouse:Hide()                          //
  123.          WinObj():Stabilize()                  //
  124.          Mouse:Show()                          //
  125.        endif                                   //
  126.                                                //
  127.  
  128.        if ! Empty(WinObj())
  129.          nKey := ( WinObj():UserSlot[2] == NIL )
  130.          MenuSys():PromptActive( VIEW_VERT, nKey )
  131.          MenuSys():PromptActive( VIEW_HORI, (! nKey) )
  132.        endif
  133.  
  134.        if ! mForce
  135.          Mouse:MouseRead()                     //  Get Event
  136.          nKey := Mouse:Ascii                   //
  137.        else
  138.          nKey := NIL
  139.          mForce := .f.
  140.        endif
  141.  
  142.        if nKey == NIL .or. nKey # 0            //
  143.          vTemp := Bar:Activate(nKey)           //  nKey
  144.          if vTemp # 0                          //  if Menu Action taken
  145.            Event := MenuEvent( vTemp )         //    Translate Menu event
  146.            nKey := vTemp                       //    nKey := Menu key
  147.          endif                                 //
  148.        else                                    //
  149.          nKey := Bar:Activate()                //  Test if mouse activates bar
  150.          if nKey # 0                           //
  151.            Event := MenuEvent( nKey )          //    Translate Menu event
  152.          endif                                 //
  153.        endif                                   //    redisplay menu bar
  154.                                                //
  155.        if Event == 0                           //
  156.          if Mouse:Button # 0                   //
  157.            Event := MouseEvent()               //    Translate Mouse event
  158.          endif                                 //
  159.        endif                                   //
  160.                                                //
  161.        if Event == 0                           //
  162.          Event := KeyboardEvent( nKey )        //    Translate Keyboard event
  163.        endif                                   //
  164.                                                //
  165.        EventProcess( Event )                   //   Event Processing
  166.                                                //
  167.     enddo                                      //
  168.  
  169.     clock( 'off' )
  170.     mouse:Hide()
  171.     Bar:Hide()
  172.     SetBlink( oldblink )
  173.     ResetDisplayMode( SaveMode() )
  174.     Set Color to
  175.     scroll(1,0)
  176.     setpos( (maxrow()/2) -1,0 )
  177.     qout( "" )
  178.     Set Cursor on
  179.  
  180. Return( NIL )
  181.  
  182.  
  183. //──────────────┐
  184. //  Set Message │
  185. //──────────────┘
  186. Function messageSet()
  187.  
  188.     Set message to maxrow()
  189.  
  190. Return( NIL )
  191.  
  192.  
  193. //────────────────────────────────────┐
  194. // System flag: Request bar redisplay │
  195. //────────────────────────────────────┘
  196. Function RedisplayBar( x )
  197.   static bar := .f.
  198.  
  199. Return( if( x == NIL, bar, bar := x ) )
  200.  
  201. //─────────────────────┐
  202. // Set up display size │
  203. //─────────────────────┘
  204. STATIC Function DisplayMode( ScreenMode )
  205.  
  206.     LOCAL CurrentMode := maxrow()+1
  207.  
  208.     scroll()
  209.     if ScreenMode # NIL
  210.       if '/43' $ ScreenMode
  211.         setmode(43,maxcol()+1)
  212.       elseif '/50' $ ScreenMode
  213.         setmode(50,maxcol()+1)
  214.       elseif '/25' $ ScreenMode
  215.         setmode(25,maxcol()+1)
  216.       endif
  217.     endif
  218.  
  219. Return( CurrentMode )
  220.  
  221.  
  222. //───────────────┐
  223. // Reset Display │
  224. //───────────────┘
  225. STATIC Function ResetDisplayMode( ScreenMode )
  226.  
  227.     if ScreenMode # NIL
  228.       if ScreenMode == 43
  229.         setmode(43,maxcol()+1)
  230.       elseif ScreenMode == 50
  231.         setmode(50,maxcol()+1)
  232.       elseif ScreenMode == 25
  233.         setmode(25,maxcol()+1)
  234.       endif
  235.     endif
  236.  
  237. Return( NIL )
  238.  
  239.  
  240. //─────────────┐
  241. //  Background │
  242. //─────────────┘
  243. Function Showbackground()
  244.  
  245.     local sColor := SetColor( desktop_color() )
  246.  
  247.  
  248.     WinBox( 2,0,maxrow()-1,maxcol(),, repl(DeskTop_char(),9) )
  249. //    @2         ,00 say replicate('▄',maxcol()+1)
  250. //    @maxrow()-1,00 say replicate('▀',maxcol()+1)
  251.     @maxrow(),00  say space( maxcol()+1 ) color message_color()
  252.     SetColor( sColor )
  253.  
  254. Return( NIL )
  255.  
  256.  
  257. Function MenuSys()
  258.  
  259.     static menusys := NIL
  260.  
  261.  
  262.     if menusys == NIL
  263.       MenuSys := g_menu()
  264.     endif
  265.  
  266. Return( menusys )
  267.  
  268.  
  269. Function GrayBar()
  270.  
  271.     local o := MenuSys()
  272.  
  273.  
  274.     aeval( o:Prompts, { |x| x:active := .f. } )
  275.     o:Display()
  276.  
  277. Return( NIL )
  278.  
  279.  
  280. Function UnGrayBar()
  281.  
  282.     local o := MenuSys()
  283.  
  284.  
  285.     aeval( o:Prompts, { |x| x:active := .t. } )
  286.     o:Display()
  287.  
  288. Return( NIL )
  289.